package com.google.code.swingonfire.component.calendar;

import java.awt.event.ActionEvent;

import javax.swing.Action;

public class JCalendarParentAction extends AbstractJCalendarAction
{

    private static final long serialVersionUID = 8006477833983572045L;

    public JCalendarParentAction(JCalendarModel model)
    {
        super(model);

        updateState();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void actionPerformed(ActionEvent e)
    {
        getModel().parentType();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void calendarModelTypeChanged()
    {
        super.calendarModelTypeChanged();

        updateState();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void calendarModelDisplayChanged()
    {
        super.calendarModelDisplayChanged();

        updateState();
    }

    protected void updateState()
    {
        putValue(Action.NAME, getModel().getTypeBasedName(getModel().getDisplayed()));
    }

}
